package com.oliet.common.vo.page;

import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;

import java.util.List;

/**
 * @Title: PageVO.java
 * @Description: 分页列表返回数据
 * @Author: Jzp
 * @Version: （版本）
 * @Date: 2022/6/17 11:14
 */
@Data
@Builder
@AllArgsConstructor
@NoArgsConstructor
public class PageVO<T>{
    /**
     * 当前页
     */
    private Long pageNo;
    /**
     * 每页显示数量
     */
    private Long pageSize;
    /**
     * 总条数
     */
    private Long totalCount;
    /**
     * 总页数
     */
    private Long totalPage;
    /**
     * 分页结果
     */
    private List<T> list;


    public PageVO(Long pageNo, Long pageSize, Long totalCount, List<T> list) {
        if (pageNo != null && pageNo > 0) {
            this.pageNo = pageNo;
        }
        if (pageSize != null && pageSize > 0) {
            this.pageSize = pageSize;
        }
        this.totalCount = totalCount;
        this.totalPage = (this.totalCount + this.pageSize - 1) / this.pageSize;
        this.list = list;
    }

}
